ask
Type
command
Summary
Displays a dialog box with a prompt, a text box for the user to enter a response, and OK and Cancel buttons.
Syntax
ask [<iconType>] <prompt> [with <defaultResponse>] [titled <windowTitle>] [as sheet]
Description
Use the ask command when a handler needs to get information from the user before continuing.
If the ask...as sheet form is used, the dialog box appears as a sheet on OS X systems. On other systems, the as sheet form has no effect and the dialog box appears normally. Attempting to open a sheet from within another sheet displays the second stack as a modal dialog box instead.
You can format the prompt text using HTML-style tags as described in the HTMLText property.
On OS X systems, there is no image for the question icon. Therefore, the information icon appears instead. In addition, the image specified by the gRevAppIcon appears if you do not specify an iconType. If you specify an iconType, the image specified by the gRevSmallAppIcon appears instead, along with the standard icon specified by the iconType.
Mobile does not support iconType and 'as sheet'.
The ask...as sheet form was introduced in LiveCode 2.0. The ability to provide formatted text for the prompt was introduced in LiveCode 2.0.
Parameters
Name | Type | Description |
---|---|---|
iconType | enum | The icon that is displayed on the left side of the dialog box. If you do not specify an icon, none is displayed. iOS and Android do not support iconType. |
prompt | string | A string of formatted (or unformatted) text. |
defaultResponse | string | A string, and is placed in the text box when the dialog box appears. If no defaultResponse is specified, the text box is empty when the dialog box appears. |
windowTitle | Appears in the title bar of the dialog box. If no windowTitle is given, the title bar is blank. |
Examples
ask "What is your name?"
ask "Please enter your occupation:" with "Geek"
ask field "Prompt" with firstGuess titled "Guess!"
ask myPrompt as sheet
ask "Please say hello:" with "DEFAULT" titled "Hello World"
ask information "Please enter your user name."
# formatted prompt text
put "Enter your <font color='red'><b>last name only</b></font>." into tPromptText
ask tPromptText
Related
property: dialogData, HTMLText
command: answer, ask file, ask password, modal, sheet, ask file with type
control structure: function
function: result
glossary: return, OS X, variable, handler, modal dialog box, dialog box, command, HTML
keyword: gRevAppIcon, it, gRevProfileReadOnly, gRevSmallAppIcon
Compatibility and Support
Introduced
LiveCode 1.0
OS
mac
windows
linux
ios
android
Platforms
desktop
mobile